<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head th:replace="~{segmentation/_right_bottom_header::_header_common(~{::title},~{::link},~{::style})}">
    <meta charset="utf-8">
    <title>数据源配置列表</title>
    <link>
    <style type="text/css"></style>
</head>
<body>
<div class="layuimini-container" id="queryDataSourceConfigList" value="0">
    <div class="layui-row">
        <div class="layuimini-main">
            <fieldset class="layui-elem-field layuimini-search">
                <legend>查询使用数据库连接信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form" id="queryDataSourceConfig-search-form" action="">
                    </form>
                </div>
            </fieldset>

            <div class="layui-btn-group" style="min-width: 100%;">
            </div>
            <table id="queryDataSourceConfigTableId" lay-filter="queryDataSourceConfigTableFilter"></table>
            <script type="text/html" id="queryDataSourceConfigCurrentTableBar">
                
            </script>

            <script type="text/html" id="enableStatusCurrentTableBar">
                {{#  if(d.enableStatus == 1){ }}
                <span style="color: limegreen;">是</span>
                {{#  } else { }}
                <span style="color: red;">否</span>
                {{#  } }}
            </script>
            <script type="text/html" id="operaterStatusCurrentTableBar">
                {{#  if(d.operaterStatus == 1){ }}
                新增
                {{#  } else { }}
                修改
                {{#  } }}
            </script>
        </div>
    </div>
</div>
<div th:replace="~{segmentation/_tail::_tail_common}"></div>
<script th:inline="javascript">

    /*<![CDATA[*/
    [# sec:authorize="hasPermission(#authorization.authentication,'button','DATA_SOURCE_CONFIG_LIST_MANAGEMENT:query_datasource_list')"]
    layui.use(['form', 'table', 'common'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            common = layui.common,
            startTime = {}, endTime = {},
            tableId = "queryDataSourceConfigTableId",
            tableIdFilter = "queryDataSourceConfigTableFilter";


        //表格数据完成后初始化
        function tableInit(res, curr, count) {
        }

        var queryDataSourceConfigTableId = table.render({
            elem: '#' + tableId,
            id: tableId,
            url: '/common/data/source/config/find/page/data/source/list',
            height: 'full-175',
            // contentType: 'application/json',
            // method: 'post',
            // even: true,
            done: tableInit,
            cols: [
                [
                    {type: "checkbox", width: 80, field: 'id', fixed: "left"},
                    {type: "numbers", width: 80, fixed: "left", title: '序号'},
                    {field: 'name', width: 300, title: '数据源名称'},
                    {field: 'code', width: 300, title: '数据源编码'},
                ]
            ],
            // initSort: {
            //      sort: "createTime", //排序字段   在接口作为参数字段  field order
            //      order: "desc"
            // },
            sort: false,
            limits: [10, 25, 50, 100],
            limit: Number.MAX_VALUE,
            page: false
        });

        // 行单击事件( 双击事件为: rowDouble )
        table.on('row(' + tableIdFilter + ')', function(obj){
            // 标注当前点击行的选中状态
            obj.setRowChecked({
                type: 'checkbox' // radio 单选模式；checkbox 复选模式
            });
        });

        // 排序事件
        table.on('sort(' + tableIdFilter + ')', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            //尽管我们的 table 自带排序功能，但并没有请求服务端。
            //有些时候，你可能需要根据当前排序的字段，重新向服务端发送请求，从而实现服务端排序，如：
            var queryData = common.getFormData($("#queryDataSourceConfig-search-form"));
            queryData.sort = obj.field;//排序字段   在接口作为参数字段  field order
            queryData.order = obj.type;//排序方式   在接口作为参数字段  field order
            //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
            common.tableRefresh(tableId, queryData);
        });

        // 监听搜索操作
        form.on('submit(queryDataSourceConfig-search)', function (data) {
            //执行搜索重载
            common.tableRefresh(tableId, data.field);
            return false;//返回false防止重复提交
        });

        startTime = laydate.render({
            elem: '#startTime',
            type: 'datetime',
            // min: -7, //7天前
            max: 'nowTime',//7天后
            btns: ['clear', 'confirm'],
            theme: 'grid',
            done: function (value, date, endDate) {
                common.setUpEndTime(endTime, value, date, 6);
            }
        });

        endTime = laydate.render({
            elem: '#endTime',
            type: 'datetime',
            max: 'nowTime',//7天后
            btns: ['clear', 'confirm'],
            theme: 'grid',
            ready: function (data) {
                var now = new Date();
                this.dateTime.hours = now.getHours();
                this.dateTime.minutes = now.getMinutes();
                this.dateTime.seconds = now.getSeconds();
            },
            done: function (value, date, endDate) {
                common.setUpStartTime(startTime, value, date, 6);
            }
        });
    });
    [/]
    /*]]>*/
</script>
</body>
</html>